package com.hanhanxiaochong.zhongxiangchuanmei.view.my.act;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.hanhanxiaochong.zhongxiangchuanmei.R;
import com.hanhanxiaochong.zhongxiangchuanmei.bean.UserRewardBean;
import com.hanhanxiaochong.zhongxiangchuanmei.presenter.my.UserRewardPresenter;
import com.hanhanxiaochong.zhongxiangchuanmei.util.SharedPreferencesUtil;
import com.hanhanxiaochong.zhongxiangchuanmei.view.base.BaseActivity;
import com.hanhanxiaochong.zhongxiangchuanmei.view.iview.IUserRewardView;
import com.hanhanxiaochong.zhongxiangchuanmei.view.my.adapter.UserRewardAdapter;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * Author : 贾桐
 * E-mail : 653773284@qq.com
 * Time   : 2018/6/9.
 * Desc   :
 */

public class UserRewardActivity extends BaseActivity<UserRewardPresenter> implements IUserRewardView {
    @BindView(R.id.img_left)
    ImageView imgLeft;
    @BindView(R.id.txt_title)
    TextView txtTitle;
    @BindView(R.id.img_right)
    ImageView imgRight;
    @BindView(R.id.rl_topview)
    RelativeLayout rlTopview;
    @BindView(R.id.txt_user_reward_money)
    TextView txtUserRewardMoney;
    @BindView(R.id.recyclerview_user_reward)
    RecyclerView recyclerviewUserReward;

    private String token;
    private UserRewardAdapter userRewardAdapter;

    @Override
    protected void initView() {
        setContentView(R.layout.activity_user_reward);
        token = SharedPreferencesUtil.getsInstances(this).getLoginInfo().getToken();
    }

    @Override
    protected void initPresenter() {
        mPresenter = new UserRewardPresenter(this);
    }

    @Override
    protected void init() {
        setTopView();
        mPresenter.getUserReward(token);
        String money = getIntent().getStringExtra("money");
        txtUserRewardMoney.setText(money);
    }

    private void setTopView() {
        ImmersionBar.with(UserRewardActivity.this).fitsSystemWindows(true).statusBarColor(R.color
                .purple).statusBarDarkFont(false).init(); //解决状态栏和布局重叠问题;
        rlTopview.setBackgroundColor(getResources().getColor(R.color.purple));
        imgLeft.setImageResource(R.mipmap.icon_close_white);
        txtTitle.setText("推荐用户奖励账户");
        txtTitle.setTextColor(getResources().getColor(R.color.white));
    }

    @OnClick({R.id.ll_leftview, R.id.ll_rightview})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_leftview:
                finish();
                break;
            case R.id.ll_rightview:
                break;
        }
    }

    @Override
    public void getUserReward(List<UserRewardBean> userRewardBeanList) {
        userRewardAdapter = new UserRewardAdapter(mContext, R.layout.item_mywallet_lsmx, userRewardBeanList);
        recyclerviewUserReward.setLayoutManager(new LinearLayoutManager(mContext));
        recyclerviewUserReward.setAdapter(userRewardAdapter);
    }
}
